<%@ tag language="java" pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<%@ attribute name="url" type="java.lang.String" required="true" description="删除url"%>
<%@ attribute name="id" type="java.lang.String" required="true" description="id"%>
<%@ attribute name="urlParam" type="java.lang.String" required="false" description="补充参数"%>
<button class="btn btn-white btn-sm" onclick="deleteAll()" data-toggle="tooltip" data-placement="top">
    <i class="fa fa-trash-o"> 删除</i>
</button>

<script type="text/javascript">
    $(document).ready(function() {
        $('#contentTable thead tr th input.i-checks').on('ifChecked', function(event){ //ifCreated 事件应该在插件初始化之前绑定
            $('#contentTable tbody tr td input.i-checks').iCheck('check');
        });

        $('#contentTable thead tr th input.i-checks').on('ifUnchecked', function(event){ //ifCreated 事件应该在插件初始化之前绑定
            $('#contentTable tbody tr td input.i-checks').iCheck('uncheck');
        });

    });

    function deleteAll(){
        // var url = $(this).attr('data-url');
        var str="";
        var ids="";
        $("#contentTable tbody tr td input.i-checks:checkbox").each(function(){
            if(true == $(this).is(':checked')){
                str+=$(this).attr("id")+",";
            }
        });
        if(str.substr(str.length-1)== ','){
            ids = str.substr(0,str.length-1);
        }
        if(ids == ""){
            top.layer.alert('请至少选择一条数据!', {icon: 0, title:'警告'});
            return;
        }
        top.layer.confirm('确认要彻底删除数据吗?', {icon: 3, title:'系统提示'}, function(index){
            window.location = "${url}?ids="+ids + "${urlParam}";
            top.layer.close(index);
        });
    }
</script><!-- 删除按钮 -->